/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.autoescola.core.entity.security;

import com.autoescola.core.entity.Entitie;
import com.autoescola.core.listener.debug.DebugListener;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author leonardo luz fernandes
 * @version 0.1
 * @since 01/11/2010
 */

@XmlRootElement(name="user")
@EntityListeners(value={DebugListener.class})
@Entitie
@Entity
@Table(name="users")
public class User implements Serializable {

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Column(name="id",nullable=false,unique=true,updatable=false)
    private Long id;

    @Column(name="username",nullable=false,unique=true,updatable=false)
    private String username;

    @Column(name="password",nullable=false,unique=false,updatable=true)
    private String password;

    @Column(name="salt",nullable=false,unique=false,updatable=false)
    private String salt;
    
    @Column(name="name",nullable=false)
    private String name;

    @Column(name="email",nullable=false,unique=true,updatable=true)
    private String email;

    @Column(name="mobile_phone_number")
    private String mobilePhoneNumber;

    @Column(name="home_phone_number")
    private String homePhoneNumber;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="logon_at",nullable=true)
    private Date logonAt;
    
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="logout_at",nullable=true)
    private Date logoutAt;
    
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="created_at",nullable=false,updatable=false)
    private Date createdAt;
    
    //Deveria ser visivel
    
    @Column(name="account_enable",nullable=false,updatable=true)
    private boolean accountEnable;
    
    @OneToMany(fetch=FetchType.EAGER)
    private List<Role> roles;
        
    public Long getId() {
        return id;
    }//end method

    public void setId(Long id) {
        this.id = id;
    }//end method

    public String getPassword() {
        return password;
    }//end method

    public void setPassword(String password) {
        this.password = password;
    }//end mehtod

    public String getUsername() {
        return username;
    }//end method

    public void setUsername(String username) {
        this.username = username;
    }//end method

    public List<Role> getRoles(){
        return this.roles;
    }//end method

    public void setRoles( List<Role> roles ){
        this.roles = roles;
    }//end method

    public boolean isAccountEnable() {
        return accountEnable;
    }

    public void setAccountEnable(boolean accountEnable) {
        this.accountEnable = accountEnable;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getHomePhoneNumber() {
        return homePhoneNumber;
    }

    public void setHomePhoneNumber(String homePhoneNumber) {
        this.homePhoneNumber = homePhoneNumber;
    }

    public Date getLogonAt() {
        return logonAt;
    }

    public void setLogonAt(Date logonAt) {
        this.logonAt = logonAt;
    }

    public Date getLogoutAt() {
        return logoutAt;
    }

    public void setLogoutAt(Date logoutAt) {
        this.logoutAt = logoutAt;
    }

    public String getMobilePhoneNumber() {
        return mobilePhoneNumber;
    }

    public void setMobilePhoneNumber(String mobilePhoneNumber) {
        this.mobilePhoneNumber = mobilePhoneNumber;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

    public Date getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }

    
    
}//end klass
